package healththink



import grails.test.mixin.*
import org.junit.*

/**
 * See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions
 */
@TestFor(FacilityUserLink)
class FacilityUserLinkTests {

	@Test
    void testFacilityUserLink() {
		User user = HealthThink.getStaticUser()
		Facility facility = HealthThink.getStaticFacility()
		
		FacilityUserLink target = new FacilityUserLink(
		   user: user,
		   userType: UserType.Contributor,
		   facility: facility
		   )
	  
		assertNotNull("(error)FacilityUserLink Target Null", target)
		assertNotNull("(error)FacilityUserLink Validation Was Not Successfull", target.validate())
		
		target = target.save(flush:true)
		FacilityUserLink expected = FacilityUserLink.findById(target.id)

		assertNotNull("(error)FacilityUserLink Target was not saved", target)
		assertNotNull("(error)Expected FacilityUserLink was null", expected)
		assertEquals("(error)Target and Expected are not Equal", target, expected)
		   
		target.delete(flush:true)
    }
}
